<div id="searchResult">
        <ul>
            <?php
            $imgs = $pager->getResults();
            foreach ($imgs as $img):
                ?>
                <li> <a href="/uploads/<?php echo $img['image_id'] ?>.jpg" class="zoom" name="<?php echo $img['name'] ?>" owner="<?php echo $img['Albums']['UsersLogin']['username'] ?>" album="<?php echo $img['Albums']['name'] ?>" price="<?php echo $img['price'] ?>">
                        <img src="/uploads/<?php echo $img['image_id'] ?>.jpg" width="80" height="51"/></a>
                        <a class="report sellerButton"></a>
                        <a onclick="fav(<?php echo $img['image_id'] ?>)" id="f<?php echo $img['image_id'] ?>"
                           class="<?php echo $img['Favorites']['user_id']==NULL ? 'notFavo':'addFavo' ;?>" x="<?php echo $img['Favorites']?>"></a>
                        
                        <div class="clear"></div>
                        <div style="padding-left:12px;">
                            <input name="<?php echo $img['image_id'] ?>" rate="1" type="radio" class="star" <?php echo round($img['avg_rate'])==1 ? 'checked': '' ?>  url="<?php echo url_for('image/rate');?>"/>
                            <input name="<?php echo $img['image_id'] ?>" rate="2" type="radio" class="star" <?php echo round($img['avg_rate'])==2 ? 'checked': '' ?>  url="<?php echo url_for('image/rate');?>"/>
                            <input name="<?php echo $img['image_id'] ?>" rate="3" type="radio" class="star" <?php echo round($img['avg_rate'])==3 ? 'checked': '' ?>  url="<?php echo url_for('image/rate');?>"/>
                            <input name="<?php echo $img['image_id'] ?>" rate="4" type="radio" class="star" <?php echo round($img['avg_rate'])==4 ? 'checked': '' ?>  url="<?php echo url_for('image/rate');?>"/>
                            <input name="<?php echo $img['image_id'] ?>" rate="5" type="radio" class="star" <?php echo round($img['avg_rate'])==5 ? 'checked': '' ?>  url="<?php echo url_for('image/rate');?>"/>
                            <p><?php echo $img['name'] ?></p>
                        </div>
                </li>
            <?php endforeach; ?>
        </ul>
    

    <?php if ($pager->haveToPaginate()): ?>
        <div class="clear"></div>
        <!--lower paging controller-->
        <div class="paginationEMP" id="results_resultsNavigationDiv"> 
            <span class="nextprev"><a href="#" onclick="pagination(<?php echo $pager->getPreviousPage() ?>)" >«previous</a></span> 
            <?php foreach ($pager->getLinks() as $page): ?>
                <?php if ($page == $pager->getPage()): ?>
                    <span class="current"><?php echo $page ?></span> 
                <?php else: ?>
                    <span><a href="#" onclick="pagination(<?php echo $page ?>)"><?php echo $page ?></a></span> 
                <?php endif; ?>
            <?php endforeach; ?>
            <span><a href="#" onclick="pagination(<?php echo $pager->getNextPage() ?>)">next»</a></span> 
        </div>
    <?php endif; ?>
        <script type="text/javascript">
            
            var addFav = "<?php echo url_for('image/addToFav');?>";
            var removeFav = "<?php echo url_for('image/removeFromFav');?>";
            function fav(id){
                alert(id);
                alert($('#f'+id).attr('x'));
                stat=$('#f'+id).attr('class');
                alert(stat);
                if(stat == 'addFavo'){
                    var url = addFav;
                }
                else{
                    var url = removeFav;
                }
                $.get(url,
                {imgId: id, z: 5},
                function(){
                    if(stat ==1){
                        $('#f'+id).attr('stat', 0);
                        $('#f'+id).removeClass('notFavo');
                        $('#f'+id).addClass('addFavo');
                    }
                    else{
                        $('#f'+id).attr('stat', 1);
                        
                        $('#f'+id).addClass('notFavo');
                        $('#f'+id).removeClass('addFavo');
                    }
                },
                "html")
            }
    </script>
</div>
